
<%@ page import="javax.servlet.ServletContext" %>

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="layout" content="main" />
        <title>系统信息</title>
        <style type="text/css">
            <!--
            .STYLE1 {
                color: #000000;
                font-weight: bold;
            }
            -->
        </style>
    </head>
    <body bgcolor="white">
        <div class="body">
            <h1>系统信息</h1>

            <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="30%" class="row-line1">浏览器信息</td>
                    <td class="row-line1"><%=request.getHeader("User-Agent")%></td>
                </tr>
                      <%
        ServletContext context = application;
        String serverInfo = context.getServerInfo();
        int majorVersion  = context.getMajorVersion();
        int minorVersion  = context.getMinorVersion();
        String servletVersion = new StringBuffer().append(majorVersion).append('.').append(minorVersion).toString();

        String vmName          = "";
        String vmVendor        = "";
        String vmVersion       = "";
        String runtimeName     = "";
        String runtimeVersion  = "";
        String osName          = "";
        String osVersion       = "";
        String cpu             = "";

        // get system info
        try {
            vmName          = System.getProperty("java.vm.name", "");
            vmVendor        = System.getProperty("java.vm.vendor", "");
            vmVersion       = System.getProperty("java.vm.version", "");
            runtimeName     = System.getProperty("java.runtime.name", "");
            runtimeVersion  = System.getProperty("java.runtime.version", "");
            osName          = System.getProperty("os.name", "");
            osVersion       = System.getProperty("os.version", "");
            cpu             = System.getProperty("sun.cpu.isalist", "");
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        // now save them
        request.setAttribute("ServerInfo", serverInfo);
        request.setAttribute("ServletVersion", servletVersion);

        request.setAttribute("vmName", vmName);
        request.setAttribute("vmVendor", vmVendor);
        request.setAttribute("vmVersion", vmVersion);
        request.setAttribute("runtimeName", runtimeName);
        request.setAttribute("runtimeVersion", runtimeVersion);
        request.setAttribute("osName", osName);
        request.setAttribute("osVersion", osVersion);
        request.setAttribute("cpu", cpu);
%>
            </table>

            <table width="95%" border="0" cellspacing="0" cellpadding="3" align="center">
                <tr>
                    <td height="30" colspan="2" class="turn-page-table"><span class="STYLE1">Request 信息</span></td>
                </tr>
                <tr>
                    <td width="30%" class="row-line1">JSP Request Method</td>
                    <td class="row-line1"><%= request.getMethod() %></td>
                </tr>
                <tr>
                    <td class="row-line2"> Request URI</td>
                    <td class="row-line2"><%= request.getRequestURI() %></td>
                </tr>
                <tr>
                    <td class="row-line1">Request Protocol</td>
                    <td class="row-line1"><%= request.getProtocol() %></td>
                </tr>
                <tr>
                    <td class="row-line2">Servlet path</td>
                    <td class="row-line2"><%= request.getServletPath() %></td>
                </tr>
                <tr>
                    <td class="row-line1">Context path</td>
                    <td class="row-line1"><%= request.getContextPath() %></td>
                </tr>
                <tr>
                    <td class="row-line2">Path info</td>
                    <td class="row-line2">
                        <% out.print(request.getPathInfo()); %>
                    </td>
                </tr>
                <tr>
                    <td class="row-line1">Query string</td>
                    <td class="row-line1">
                        <% out.print(request.getQueryString()); %>
                    </td>
                </tr>
                <tr>
                    <td height="21" class="row-line2">Content length</td>
                    <td class="row-line2"><%= request.getContentLength() %></td>
                </tr>
                <tr>
                    <td class="row-line1">Content type</td>
                    <td class="row-line1"><%= request.getContentType() %></td>
                </tr>
                <tr>
                    <td class="row-line2">服务器名称</td>
                    <td class="row-line2"><%= request.getServerName() %></td>
                </tr>
                <tr>
                    <td class="row-line1">服务器端口</td>
                    <td class="row-line1"><%= request.getServerPort() %></td>
                </tr>
                <tr>
                    <td class="row-line2">远程用户</td>
                    <td class="row-line2"><%= request.getRemoteUser() %></td>
                </tr>
                <tr>
                    <td class="row-line1">远程地址</td>
                    <td class="row-line1"><%= request.getRemoteAddr() %></td>
                </tr>
                <tr>
                    <td class="row-line2">远程主机</td>
                    <td class="row-line2"><%= request.getRemoteHost() %></td>
                </tr>
                <tr>
                    <td class="row-line1">Authorization scheme</td>
                    <td class="row-line1"><%= request.getAuthType() %></td>
                </tr>
                <tr>
                    <td class="row-line2">区域</td>
                    <td class="row-line2"><%= request.getLocale() %></td>
                </tr>
                <tr>
                    <td class="row-line1">Root Real Path</td>
                    <td class="row-line1">${rootRealPath}</td>
                </tr>
                <tr>
                    <td class="row-line2">WEB-INF/classes Real Path</td>
                    <td class="row-line2">${classesRealPath}</td>
                </tr>
                <tr>
                    <td class="row-line1">Servlet Context Name</td>
                    <td class="row-line1">${servletContextName}</td>
                </tr>
            </table>
            <br>
            <br>
            <table width="95%" border="0" cellspacing="0" cellpadding="3" align="center">
                <tr>
                    <td height="28" colspan="2" class="turn-page-table"><span class="STYLE1">应用服务器信息</span></td>
                </tr>
                <tr>
                    <td width="30%" class="row-line1">应用服务器名称</td>
                    <td class="row-line1"><%=(String)request.getAttribute("ServerInfo")%></td>
                </tr>
                <tr>
                    <td class="row-line2">Servlet版本号</td>
                    <td class="row-line2"><%=(String)request.getAttribute("ServletVersion")%></td>
                </tr>
            </table>

            <p>

            <table width="95%" border="0" cellspacing="0" cellpadding="3" align="center">
                <tr>
                    <td height="31" colspan="2" class="turn-page-table"><span class="STYLE1">系统信息</span></td>
                </tr>
                <tr>
                    <td width="30%" class="row-line1">虚拟机名称</td>
                    <td class="row-line1"><%=(String)request.getAttribute("vmName")%></td>
                </tr>
                <tr>
                    <td class="row-line2">虚拟机供应商</td>
                    <td class="row-line2"><%=(String)request.getAttribute("vmVendor")%></td>
                </tr>
                <tr>
                    <td class="row-line1">虚拟机版本</td>
                    <td class="row-line1"><%=(String)request.getAttribute("vmVersion")%></td>
                </tr>
                <tr>
                    <td class="row-line2">运行环境名称</td>
                    <td class="row-line2"><%=(String)request.getAttribute("runtimeName")%></td>
                </tr>
                <tr>
                    <td class="row-line1">运行环境版本</td>
                    <td class="row-line1"><%=(String)request.getAttribute("runtimeVersion")%></td>
                </tr>
                <tr>
                    <td class="row-line2">操作系统名称</td>
                    <td class="row-line2"><%=(String)request.getAttribute("osName")%></td>
                </tr>
                <tr>
                    <td class="row-line1">操作系统版本</td>
                    <td class="row-line1"><%=(String)request.getAttribute("osVersion")%></td>
                </tr>
                <tr>
                    <td class="row-line2">cpu</td>
                    <td class="row-line2"><%=(String)request.getAttribute("cpu")%></td>
                </tr>
                <%
                Runtime runtime = Runtime.getRuntime();
                long totalMemory = runtime.totalMemory();
                long freeMemory  = runtime.freeMemory();
                long totalKB = totalMemory/1024;
                long freeKB  = freeMemory/1024;
                %>
                <tr>
                    <td class="row-line1">总共内存</td>
                    <td class="row-line1"><%=totalKB%> KB</td>
                </tr>
                <tr>
                    <td class="row-line2">空闲内存</td>
                    <td class="row-line2"><%=freeKB%> KB</td>
                </tr>
            </table>


        </div>
    </body>
</html>
